package org.ns.framework.webmvc;

/**
 * 应答实体输出的key名称.
 * 
 * @author zhangxingyu
 *
 */
public interface ResponseEntityKey {
	
	public static final String KEY = "ResponseEntityKey";

	String getStatusName();

	String getStateName();

	String getContentName();

	String getMessageName();

	String getErrplaceName();

	default String getRequestIdName() {
		return "requestId";
	}
	
	default String getLocaleMessageName() {
		return null;
	}

	default boolean existStatusName() {
		return getStatusName() != null;
	}

	default boolean existStateName() {
		return getStateName() != null;
	}

	default boolean existContentName() {
		return getContentName() != null;
	}

	default boolean existMessageName() {
		return getMessageName() != null;
	}

	default boolean existErrplaceName() {
		return getErrplaceName() != null;
	}

	default boolean existRequestIdName() {
		return getRequestIdName() != null;
	}
	
	default boolean existLocaleMessageName() {
		return getLocaleMessageName() != null;
	}

	public static class DefaultResponseEntityKey implements ResponseEntityKey {

		public static DefaultResponseEntityKey defaultInstance = new DefaultResponseEntityKey();

		@Override
		public String getStatusName() {
			return "status";
		}

		@Override
		public String getStateName() {
			return "state";
		}

		@Override
		public String getContentName() {
			return "content";
		}

		@Override
		public String getMessageName() {
			return "message";
		}

		@Override
		public String getErrplaceName() {
			return "errplace";
		}

	}
}
